<script>
	import Vue from 'vue';
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex';
	export default {
		onLaunch: function() {
			console.log('App Launch');
			let that = this;
			setTimeout(() => {
				uni.getSystemInfo({
					success: function(e) {
						// #ifndef MP
						Vue.prototype.StatusBar = e.statusBarHeight;
						if (e.platform == 'android') {
							Vue.prototype.CustomBar = e.statusBarHeight + 60;
						} else {
							Vue.prototype.CustomBar = e.statusBarHeight + 55;
						}
						// #endif

						// #ifdef MP-WEIXIN
						Vue.prototype.StatusBar = e.statusBarHeight;
						let custom = wx.getMenuButtonBoundingClientRect();
						Vue.prototype.Custom = custom;
						Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
						// #endif

						// #ifdef MP-ALIPAY
						Vue.prototype.StatusBar = e.statusBarHeight;
						Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
						// #endif
						/* 计算一下 宽高比例 */
						console.log('Vue.prototype.CustomBar', Vue.prototype.CustomBar, custom);
						that.SET_CustomBar(Vue.prototype.CustomBar);
						that.SET_StatusBar(Vue.prototype.StatusBar);
					}
				});
			});
			// #ifdef APP-PLUS
			//默认生成一个32位，唯一表示
			this.SET_OpenId(uni.$u.guid());
			// #endif
			var icommon = requirePlugin('ICDeviceManager');
			this.icommon = icommon;
			this.ICDeviceManager = new icommon.ICDeviceManager();
		},
		computed: {
			...mapState(['userInfo'])
		},
		onShow: function() {
			console.log('App Show');
		},
		onHide: function() {
			console.log('App Hide');
		},
		methods: {
			...mapMutations(['SET_CustomBar', 'SET_StatusBar', 'SET_OpenId']),
			// 设置监听器
			watch: function(ctx, aim, obj) {
				Object.keys(obj).forEach(key => {
					this.observer(aim, key, aim[key], function(value) {
						obj[key].call(ctx, value);
					});
				});
			},
			// 监听属性，并执行监听函数
			observer: function(data, key, val, fn) {
				Object.defineProperty(data, key, {
					configurable: true,
					enumerable: true,
					get: function() {
						return val;
					},
					// 重写set函数，就能在其属性改变时触发回调
					set: function(newVal) {
						if (newVal === val) return;
						fn && fn(newVal);
						val = newVal;
					}
				});
			}
		}
	};
</script>
<style lang="scss">
	/*每个页面公共css */
	/*每个页面公共css */
	@import '@/uni_modules/uview-ui/index.scss';
	@import '@/colorui/main.css';
	page {
		font-size: 28rpx;
		color: #333333;
		background: #fff;
		height: 100%;
		width: 100%;
	}

	.pageview {
		background: #f2f2f2;
		height: 100vh;
		overflow: auto;
	}

	.noData {
		padding: 40upx 0;
	}

	.noData image {
		width: 330upx;
		height: 250upx;
		margin: 0 auto;
		display: block;
	}
</style>

<style lang="scss">
	/deep/.u-input__content__clear .u-icon__icon {
		font-size: 22rpx !important;
	}

	/deep/.u-upload__wrap__preview .u-icon__icon {
		font-size: 22rpx !important;
		line-height: 28rpx !important;
	}

	.card {
		box-shadow: 0 1px 6upx rgba(0, 0, 0, 0.1);
		border-radius: 10upx;
		background: #fff;
		overflow: hidden;
	}
</style>